package masterjava.common.client;

import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 * MasterJava.ru
 * <p/>
 * User: GKislin
 * Date: 28.02.11
 */
public class EjbClient<ITF> extends AbstractClient<ITF, String>{
    private static final InitialContext CTX;

    static {
        try {
            CTX = new InitialContext();
        } catch (NamingException e) {
            throw LOGGER.getIllegalStateException("javax.naming.InitialContext coudn't be initialized", e);
        }
    }

    public EjbClient(String ejbName) {
        super(ejbName, null);
    }

    @Override
    protected boolean isClientUnavailable(Throwable e) {
        // TODO
        return false;
    }

    @Override
    protected boolean isClientReinitialize(Throwable e) {
        // TODO
        return false;
    }

    @Override
    protected ITF doInit() throws NamingException {
        return (ITF) CTX.lookup(serviceName);
    }
}
